layui.use(['form', 'admin','ax'], function () {
    var $ = layui.jquery;
    var form = layui.form;
    var $ax = layui.ax;
    var admin = layui.admin;





    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax("/task/save", function (data) {
            if(data.code == 0){
                top.layer.msg("新增成功!", {icon: 1});
                admin.putTempData('formOk', true);
                admin.closeThisDialog();
            }else{
                top.layer.msg("新增失败,"+data.msg + "!", {icon: 2});
            }
        }, function (data) {
            top.layer.msg("新增失败,"+data.msg + "!", {icon: 2});
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });

    $('#cancel').click(function(){
        admin.closeThisDialog();
    });
});